home *** CD-ROM | disk | FTP | other *** search
Wrap
/* * Copyright (C) 1993, 1994, Silicon Graphics, Inc. * All Rights Reserved. * * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; * the contents of this file may not be disclosed to third parties, copied or * duplicated in any form, in whole or in part, without the prior written * permission of Silicon Graphics, Inc. * * RESTRICTED RIGHTS LEGEND: * Use, duplication or disclosure by the Government is subject to restrictions * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data * and Computer Software clause at DFARS 252.227-7013, and/or in similar or * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - * rights reserved under the Copyright Laws of the United States. */ #include <stdio.h> /* standard libraries */ #include <stdlib.h> #include <unistd.h> #include <math.h> #include <sys/time.h> #include <Xm/Xm.h> /* motif lib */ #include <X11/Xirisw/GlxMDraw.h> /* GL/X widget lib */ #include <X11/StringDefs.h> /* X11 libs */ #include <X11/keysym.h> #include <Xm/Separator.h> /* motif widget libs */ #include <Xm/Form.h> #include <Xm/CascadeB.h> #include <Xm/PushB.h> #include <Xm/ToggleB.h> #include <Xm/RowColumn.h> #include <Xm/Frame.h> #include "interfmotif.h" /* private header files */ #include "exinterfmotif.h" #include "bookglo.h" /* #include "exbookglo.h" #include "shelves.h" */ #include "globals.h" #include "exglobals.h" #include "interf.h" #define MOTION 1 #define NO_MOTION 0 #define PRESSED TRUE #define RELEASED FALSE #define DOUBLETIME .6 /* functions */ extern struct indexlist *find_keyword(); extern void setup_colors_widget(); /* global variables */ static int side; /* side of page: left side is "back", right "front" */ static int gSide; /* used by Delete Demo callback */ static int old_x, old_y, oldxpagendx, oldypagendx; /* used for dragging */ /* global structs */ struct iconstruct *tmpiconlist; /* temp. buffer to track who's on current page */ struct pagestruct *thispage; /* tracks which page we're looking at */ static Boolean MW_Button1_mode; /* tracks whether buttons are down or up */ static Boolean MW_Button2_mode; static Boolean MW_dragging; /* tracks if an icon is being dragged */ static Boolean Change; /* determines if "really quit" window come up */ static long winsize_x, winsize_y; /* tracks size of window */ Boolean in_main_window; /* tracks cursor focus */ static int prevmotion; /* used for icon highlighting */ Boolean AltKeyPressed = FALSE; /* tracks alt key status */ /*global widgets */ Widget MainGL; /* the main GL/X window. Parent is a frame */ Widget CBbutton, ZLbutton, ZRbutton, ZObutton; /* close book, zoom left/right/out */ Widget OpenButton, AppendButton;/* Open, Append, book */ Boolean use_pups = FALSE; /* determines if menus use popups or not */ static GLXconfig glxconfig_Main[] = { /* by default, GLX window is double */ {GLX_NORMAL, GLX_DOUBLE, TRUE}, /* buffered, RGB, no zbuffer size, */ {GLX_NORMAL, GLX_ZSIZE, GLX_NOCONFIG}, /* and two buffers */ {GLX_NORMAL, GLX_RGB, TRUE}, {GLX_OVERLAY, GLX_BUFSIZE, 2}, {0, 0, 0} }; static char defaultTranslations[] = /* map X events to glx */ "<Motion>: glxInput() \n\ <EnterNotify>: glxInput() \n\ <LeaveNotify>: glxInput()"; /* some dummy routine for compile without uimx stuff */ void setChange(Boolean val) { Change = val; } redrawevent(long val) { #ifdef DEBUG printf(" dummy redraw event routine \n"); #endif } /* end of dummy routines */ /************************************************************ * * Calculate the colors to approximate the colors in the icons. * ************************************************************/ initcolors() { int i, j; int cndx ; float m, incr; cndx = 26; for (i = 0; i < 16; i++) { for (j = i+1; j < 16; j++) { morecolors[cndx][0] = (morecolors[i+10][0] + morecolors[j+10][0]) / 2; morecolors[cndx][1] = (morecolors[i+10][1] + morecolors[j+10][1]) / 2; morecolors[cndx][2] = (morecolors[i+10][2] + morecolors[j+10][2]) / 2; ++cndx; } } incr = 1.0 / 16.0; m = 0; for (i = cndx; i < cndx+16; i++) { morecolors[i][0] = morecolors[2][0] * (1.0 - m) + morecolors[3][0] * m; morecolors[i][1] = morecolors[2][1] * (1.0 - m) + morecolors[3][1] * m; morecolors[i][2] = morecolors[2][2] * (1.0 - m) + morecolors[3][2] * m; m = m + incr; } } void installcmap(Widget toplevel, Widget gl) { Window window_list[3]; Window overlay, popup; Arg args[5]; int n = 0; XtSetArg(args[n], GlxNoverlayWindow, &overlay); n++; XtSetArg(args[n], GlxNpopupWindow, &popup); n++; XtGetValues(gl, args, n); n = 0; if (overlay) { window_list[n] = overlay; n++; } if (popup) { window_list[n] = popup; n++; } window_list[n] = XtWindow(toplevel); n++; XSetWMColormapWindows(XtDisplay(toplevel), XtWindow(toplevel), window_list, n); } /* overlay stuff */ Window overlayWindow(Widget w) { Arg args[1]; Window overlayWindow; XtSetArg(args[0], use_pups?GlxNpopupWindow:GlxNoverlayWindow, &overlayWindow); XtGetValues(w, args, 1); return (overlayWindow); } Matrix ID = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0}; void setview() { long winsize_x, winsize_y; getsize(&winsize_x, &winsize_y); /* viewport(0.0, (float)winsize_x, 0.0, (float)(winsize_y)); */ mmode(MPROJECTION); loadmatrix(ID); perspective(150.0, (float)winsize_x / (float)(winsize_y), 1, 505); if (closeup == 0) { lookat(0.0, 6.5, 55.5, 0.0, 6.5, 0.0, 0.0); } else if (closeup < 0) /* zoom to left side */ { lookat(-5.0, 5.5, 37.5, -5.0, 5.5, 0.0, 0.0); } else if (closeup > 0) /* zoom to right side */ { lookat(5.0, 5.5, 37.5, 5.0, 5.5, 0.0, 0.0); } mmode(MVIEWING); loadmatrix(ID); } void dooverlayview() { GLXwinset (XtDisplay(MainGL), overlayWindow(MainGL)); setview(); } /************************************************************ * * Set up the viewing matrix for the book. * ************************************************************/ dobookview() { GLXwinset (XtDisplay(MainGL), XtWindow(MainGL) ); setview(); } #include <audio.h> void silentALerror(long errnum, const char* fmt, ...) {} Boolean audio_lib_capable() { /* don't concern the user with an error message */ ALerrfunc originalErrorHandler = ALseterrorhandler(silentALerror); ALport tmpPort = ALopenport("test","w",0); Boolean result = (Boolean)tmpPort; if (tmpPort) ALcloseport(tmpPort); ALseterrorhandler(originalErrorHandler); return (result); } /************************ for timing */ clock_sec(s) float *s; { float tmp1,tmp2; long err; struct timeval tp; struct timezone tzp; err = gettimeofday(&tp,&tzp); tmp1 = (float)(tp.tv_usec)/1000000.0; tmp2 = tp.tv_sec%10000; *s = tmp1+tmp2; return; } /******** end of 'for timing' */ void initCB_Main( Widget w, XtPointer client_data, XtPointer call_data) { static float top_lt[] = {AMBIENT, 0.6, 0.6, 0.6, LCOLOR, .6, .6, .6, POSITION, -1.0, 0.0, 1.0, 0.0, LMNULL}; static float simple_lm[] = {AMBIENT, 0.6, 0.6, 0.6, LOCALVIEWER, 0.0, LMNULL}; static float paper[] = {EMISSION, 0.0, 0.0, 0.0, AMBIENT, 0.5, 0.5, 0.5, DIFFUSE, 0.6, 0.6, 0.6, SPECULAR, .3, .3, .3, SHININESS, 10.0, LMNULL}; dooverlayview(); mapcolor(PUP_BLACK, 0, 0, 0); mapcolor(PUP_WHITE, 255, 255, 255); mapcolor(PUP_COLOR, 255, 0, 0); dobookview(); /* need to test to know when to set subpixel(TRUE) */ /* char version[12]; gversion(version); if (strncmp(version,"GL4DPI") != 0 && (getgdesc(GD_SUBPIXEL_LINE) || getgdesc(GD_SUBPIXEL_PNT) || getgdesc(GD_SUBPIXEL_POLY) )) subpixel(TRUE); */ initcolors(); mk_open_arrays(); mk_turn_arrays(); initshelves(); lmdef(DEFMATERIAL, 1, 0, paper); lmdef(DEFLIGHT, 1, 0, top_lt); lmdef(DEFLMODEL, 1, 0, simple_lm); /*( Groupwin = -1; Indexwin = -1; ADwin = -1; Rewin = -1; */ MW_Button1_mode = RELEASED; MW_Button2_mode = RELEASED; } void overlayexposeCB_Main( Widget w, XtPointer client_data, XtPointer call_data) { unhighlighticon(); } void exposeCB_Main( Widget w, XtPointer client_data, XtPointer call_data) { GLXwinset (XtDisplay(w), XtWindow(w) ); drawscene(0); } void resizeCB_Main( Widget w, XtPointer client_data, XtPointer call_data) { GLXwinset (XtDisplay(w), XtWindow(w) ); reshapeviewport(); } int get_picked(short picbuf[], int hits) { int i, j, c, num; int picked; c = 0; picked = 100; for (i = 0; i < hits; i++) { num = picbuf[c++]; for (j = 0; j < num; j++) { if (picbuf[c] < 90) picked = picbuf[c++]; else c++; } } return(picked); } int do_picking() { short picbuf[PICBUFSIZ]; int hits; int picked; int i; dobookview(); pick(picbuf, PICBUFSIZ); dobookview(); initnames(); pickdrawscene(0); hits = endpick(picbuf); picked = get_picked(picbuf, hits); dobookview(); return(picked); } void open_new_book(Boolean motion, int picked) { short picbuf[PICBUFSIZ]; int hits; int i; if (picked >= 0 && picked < numberofbooks) { XtVaSetValues(CBbutton, XmNsensitive, TRUE, NULL); currentbook = picked; unhighlighticon(); dobookview(); /* unhighlight puts us in overlay window */ /* total kludge */ curgroup = firstgroup; i = 0; while (i < picked && curgroup != NULL) { curgroup = curgroup->nextgrp; i++; } if (curgroup == NULL) curgroup = firstgroup; leftpage = NULL; middlepage = NULL; rightpage = curgroup->firstpage; thispage = rightpage; /* end of total kludge */ OPENBOOK = TRUE; selected = -1; prevselection = -1; seliconptr = NULL; if (motion) { initxflip(picked); if (Audio) system("playaiff /usr/lib/sounds/prosonus/musictags/tag2.aiff & "); flipbook(); OPENBOOK = TRUE; selected = -1; prevselection = -1; seliconptr = NULL; /* stuff to open the book */ color_mult = 1.0; openbook(0); /* 0 is rotate flag */ } else { OPENBOOK = TRUE; selected = -1; prevselection = -1; seliconptr = NULL; } drawscene(0); } } void inputCB_Main( Widget w, XtPointer client_data, XtPointer call_data) { int picked; int i; int mx, my; int ix, iy, xpagendx, ypagendx; struct grptmpltstruct *group_to_move, *tmpgrp, *pgrp, *ngrp; char *buffer; int bytes; KeySym key_sym; XComposeStatus status; GlxDrawCallbackStruct *glcall; XKeyEvent *keyevent; long wx, wy; glcall = (GlxDrawCallbackStruct *)call_data; buffer = (char *)malloc(5); for (i = 0; i < 5; i++) buffer[i] = '\0'; dobookview(); switch(glcall->event->type) { case EnterNotify: in_main_window = TRUE; break; case LeaveNotify: in_main_window = FALSE; break; case KeyPress: keyevent = (XKeyEvent *)glcall->event; i = XLookupString(keyevent, buffer, 1, &key_sym, &status); if (key_sym == XK_Alt_R || key_sym == XK_Alt_L) { AltKeyPressed = TRUE; } break; case KeyRelease: keyevent = (XKeyEvent *)glcall->event; i = XLookupString(keyevent, buffer, 1, &key_sym, &status); if (key_sym == XK_Alt_R || key_sym == XK_Alt_L) { AltKeyPressed = FALSE; } break; case ButtonPress: picked = do_picking(); switch (glcall->event->xbutton.button) { case Button1: MW_Button1_mode = PRESSED; if (OPENBOOK) { getsize(&winsize_x, &winsize_y); mx = glcall->event->xbutton.x; my = winsize_y - glcall->event->xbutton.y; old_x = mx; old_y = my; if (picked < 0) { thispage = leftpage; side = BACK; picked = -picked - 1; } else { thispage = rightpage; side = FRONT; } if (thispage != NULL && picked >= 0 && picked < 80) { selected = picked; selectedpage = thispage; if (side == FRONT) tmpiconlist = thispage->fronticons; else tmpiconlist = thispage->backicons; i = 0; while (i != selected || (!tmpiconlist->ok && Hide)) { if (!Hide || tmpiconlist->ok) i++; tmpiconlist = tmpiconlist->nexticon; } seliconptr = tmpiconlist; if (prevselection >= 0) { undrawselectedicon(prevpage, prevselection); } drawselectedicon(thispage, selected); prevpage = thispage; /* old way if (selected != prevselection) { if (prevselection >= 0) { undrawselectedicon(prevpage, prevselection); } drawselectedicon(thispage, selected); prevpage = thispage; } */ } else if (picked == 80) { prevselection = -1; selected = -1; unhighlighticon(); outlineleftedge(); } else if (picked == 81) { prevselection = -1; selected = -1; unhighlighticon(); outlinerightedge(); } else if (picked > 81) { selected = -1; picked = -1; seliconptr = NULL; selectedpage = NULL; if (prevselection >= 0) { undrawselectedicon(prevpage, prevselection); } prevpage = thispage; } /* begin Gretch experiment */ if (picked == 80 && leftpage != NULL) { selectedpage = NULL; selected = -1; prevselection = -1; unhighlighticon(); dobookview(); /* unhighlight puts us in overlay window */ leftpage->direction = -leftpage->direction; turnpage(0); } else if (picked == 81 && rightpage != NULL) { selectedpage = NULL; selected = -1; prevselection = -1; unhighlighticon(); dobookview(); /* unhighlight puts us in overlay window */ rightpage->direction = -rightpage->direction; turnpage(1); } /* end Gretch experiment */ } else { selected = picked; unhighlighticon(); if (picked >= 0 && picked < numberofbooks) highlightbookonshelf(picked); } break; case Button2: MW_Button2_mode = PRESSED; break; case Button3: break; } break; case ButtonRelease: picked = do_picking(); switch (glcall->event->xbutton.button) { case Button1: MW_Button1_mode = RELEASED; if (!OPENBOOK) { if (MW_dragging) { MW_dragging = !MW_dragging; if (selected >= 0 && selected < numberofbooks) { /* find the pointer to the selected group and the prevselection/picked */ if (picked > numberofgroups || picked < 0) picked = prevselection; if (picked >= 0 && picked != selected && picked != selected+1) { Change = TRUE; tmpgrp = firstgroup; for (i = 0; i < selected; i++) tmpgrp = tmpgrp->nextgrp; group_to_move = tmpgrp; tmpgrp = firstgroup; for (i = 0; i < picked; i++) tmpgrp = tmpgrp->nextgrp; /* take the selected group out of the linked list */ pgrp = group_to_move->prevgrp; ngrp = group_to_move->nextgrp; if (pgrp != NULL) pgrp->nextgrp = ngrp; else firstgroup = ngrp; if (ngrp != NULL) ngrp->prevgrp = pgrp; else lastgroup = pgrp; /* add the selected group in front of the picked/ prevselection group */ pgrp = tmpgrp->prevgrp; ngrp = tmpgrp->nextgrp; group_to_move->prevgrp = pgrp; group_to_move->nextgrp = tmpgrp; tmpgrp->prevgrp = group_to_move; if (pgrp != NULL) pgrp->nextgrp = group_to_move; else firstgroup = group_to_move; drawscene(0); } unhighlighticon(); if (picked >=0 && picked < numberofbooks) { if (selected < picked) highlightbookonshelf(picked-1); else highlightbookonshelf(picked); } } } else open_new_book(MOTION, picked); } else /* a book is open */ { #ifdef DEBUG if (picked == 80 && leftpage != NULL) { selectedpage = NULL; selected = -1; prevselection = -1; unhighlighticon(); dobookview(); /* unhighlight puts us in overlay window */ leftpage->direction = -leftpage->direction; turnpage(0); } else if (picked == 81 && rightpage != NULL) { selectedpage = NULL; selected = -1; prevselection = -1; unhighlighticon(); dobookview(); /* unhighlight puts us in overlay window */ rightpage->direction = -rightpage->direction; turnpage(1); } #endif /* else */ if (MW_dragging) { MW_dragging = FALSE; if (in_main_window) { if (xpagendx != -1 && ypagendx != -1) { if (curgroup->nameptr == find_keyword("Master Index")) { sprintf(msgstring, "Icons in this book can not be moved."); popup_Message(); } else { #ifdef DEBUG if (seliconptr == NULL) printf(" it thinks i'm dragging seliconptr = NULL \n"); else { printf(" old page ndx %d %d new %d %d \n", seliconptr->xposition_ndx, seliconptr->yposition_ndx, xpagendx, ypagendx); #endif if (xpagendx >= 0 && xpagendx < 5 && ypagendx >= 0 && ypagendx < 4) { seliconptr->xposition_ndx = xpagendx; seliconptr->yposition_ndx = ypagendx; drawscene(0); } #ifdef DEBUG } #endif } } } else /* in_main_window == FALSE */ { tmpiconlist = (struct iconstruct *)malloc(sizeof(struct iconstruct) ); if (newgroupiconlist == NULL) newgroupiconlist = tmpiconlist; else newgrouplasticon->nexticon = tmpiconlist; if (newgrouplasticon != NULL) { tmpiconlist->xposition_ndx = newgrouplasticon->xposition_ndx+1; tmpiconlist->yposition_ndx = newgrouplasticon->yposition_ndx; } else { tmpiconlist->xposition_ndx = 0; tmpiconlist->yposition_ndx = 3; } if (tmpiconlist->xposition_ndx > 4) { tmpiconlist->xposition_ndx = 0; tmpiconlist->yposition_ndx--; } if (tmpiconlist->yposition_ndx < 0) tmpiconlist->yposition_ndx = 0; newgrouplasticon = tmpiconlist; tmpiconlist->iconptr = seliconptr->iconptr; tmpiconlist->ok = seliconptr->ok; tmpiconlist->nexticon = NULL; setgroupwin(); drawgroupwin(); } prevselection = selected; } else { if (picked < 0) { thispage = leftpage; side = BACK; picked = -picked - 1; } else { thispage = rightpage; side = FRONT; } gSide = side; /* times to use for testing for double click */ clock_sec(&tmptime); elapsed_time = tmptime - click1; click1 = tmptime; if (elapsed_time <= DOUBLETIME) { /* printf(" double click \n"); printf(" selected = %d prev = %d \n", selected, prevselection); */ if (selected == prevselection && selected >= 0) { unhighlighticon(); dobookview(); /* unhighlight puts us in overlay window */ if (AltKeyPressed) { if (seliconptr->iconptr->alt_command != NULL) system(seliconptr->iconptr->alt_command); } else { if (seliconptr->iconptr->startstring != NULL) system(seliconptr->iconptr->startstring); } } } /* else { #ifdef DEBUG printf(" button release left mouse seliconptr = %d \n",seliconptr); #endif } */ prevselection = selected; } } break; case Button2: MW_Button2_mode = RELEASED; if (!OPENBOOK) open_new_book(NO_MOTION, picked); else /* a book is open */ { /* click on left arrow, don't watch page turn */ if (picked == 80 && leftpage != NULL) /* left side */ { rightpage = leftpage; leftpage = leftpage->prevpage; rightpage->direction = 1; } /* click on right arrow, don't watch page turn */ else if (picked == 81 && rightpage != NULL) /* right side */ { leftpage = rightpage; rightpage = rightpage->nextpage; leftpage->direction = -1; } /*setcursor(0, 0, 0); */ drawscene(0); } break; case Button3: if (OPENBOOK) { selected = -1; prevselection = -1; seliconptr = NULL; close_book(); drawscene(0); } break; } break; case MotionNotify: if (!OPENBOOK) { picked = do_picking(); if (MW_Button1_mode && !ViewOnly) { if (selected >= 0 && selected < numberofbooks) { if (picked >= 0 && picked < numberofbooks && picked != prevmotion) { MW_dragging = TRUE; unhighlighticon(); highlightbookonshelf(picked); shownewposition(picked); prevmotion = picked; } else if (picked < 0 || picked >= numberofbooks) { unhighlighticon(); } } } else { if (picked >= 0 && picked < numberofbooks) { if (picked != prevmotion) { unhighlighticon(); highlightbookonshelf(picked); prevmotion = picked; } } else { unhighlighticon(); prevmotion = -1; } } } else /* a book is open */ { if (MW_Button1_mode && !ViewOnly) /* left mouse is down */ { /* printf(" selected = %d picked = %d\n",selected, picked); */ if (selected != -1) { ix = glcall->event->xbutton.x; iy = winsize_y - glcall->event->xbutton.y; #ifdef DEBUG if (ix < 0 || ix > glcall->width || iy < 0 || iy > glcall->height) printf(" OUT OF WINDOW \n"); #endif if (abs(old_x-ix) > 15 || abs(old_y - iy) > 15) { MW_dragging = TRUE; old_x = ix; old_y = iy; if (closeup > 0 || (closeup == 0 && ix > winsize_x/2)) { if (rightpage == NULL) { xpagendx = -1; ypagendx = -1; } else { findrightpagesquare(&xpagendx, &ypagendx); if (xpagendx < 0 || ypagendx < 0) { unhighlighticon(); dobookview(); /* unhighlight puts us in overlay window */ } else if (xpagendx!=oldxpagendx || ypagendx!= oldypagendx) { oldxpagendx = xpagendx; oldypagendx = ypagendx; highlightsquare(FRONT, xpagendx, ypagendx); } } } else if (closeup < 0 || (closeup == 0 && ix < winsize_x/2)) { if (leftpage == NULL) { xpagendx = -1; ypagendx = -1; } else { findleftpagesquare( &xpagendx, &ypagendx); if (xpagendx < 0 || ypagendx < 0) { unhighlighticon(); dobookview(); /* unhighlight puts us in overlay window */ } else if (xpagendx!=oldxpagendx || ypagendx!= oldypagendx) { oldxpagendx = xpagendx; oldypagendx = ypagendx; highlightsquare(BACK, xpagendx, ypagendx); } } } } } else if (picked == 80) { picked = do_picking(); if (picked != 80) unhighlighticon(); } else if (picked == 81) { picked = do_picking(); if (picked != 81) unhighlighticon(); } } else if (!MW_Button2_mode) /*a book is open, no buttons are down */ { picked = do_picking(); /* mx = glcall->event->xbutton.x; my = winsize_y - glcall->event->xbutton.y; */ if (picked < 0) { thispage = leftpage; side = BACK; picked = -1 - picked; } else { thispage = rightpage; side = FRONT; } if (thispage != NULL) { /* if (side == FRONT) curnumicons = thispage->frontnumicons; else if (side == BACK) curnumicons = thispage->backnumicons; else curnumicons = 0; */ /* locate highlight the icon */ if (picked < 0) { unhighlighticon(); } else if (picked != prevmotion && picked < 21) { prevmotion = picked; highlighticon(picked, thispage, side); } else if (picked == 80) /* left side */ { prevmotion = -1; unhighlighticon(); outlineleftedge(); } else if (picked == 81) /* right side */ { prevmotion = -1; unhighlighticon(); outlinerightedge(); } } else /* thispage equals NULL here */ { unhighlighticon(); prevmotion = -1; } } } break; } } void menuCB_debug_index(Widget w, XtPointer client_data, XtPointer call_data) { print_keywords(); } void menuCB_debug_demos(Widget w, XtPointer client_data, XtPointer call_data) { print_icons(); } void menuCB_debug_books(Widget w, XtPointer client_data, XtPointer call_data) { if (OPENBOOK) print_groups(curgroup); else print_groups(NULL); } void menuCB(Widget w, XtPointer client_data, XtPointer call_data) { char *str; str = (char *)client_data; printf("menu option %s not implemented yet \n", str); } void menuCB_AddB(Widget w, XtPointer client_data, XtPointer call_data) { if (numberofgroups > 0) { Change = TRUE; initgpform(); setgpform(NULL); initgroup(); EditGroupFlag = 0; if (MotifGroupWin <= 0) { popup_CreateGroup(); MotifGroupWin = 99; InterfaceWinOpen++ ; } } else { sprintf(msgstring, "Because this is an early version of the\ndemobook, you must read in a demobook file\nbefore you can create a new book. Please\nchoose Open under the File Menu."); popup_Message(); } } void menuCB_AddD(Widget w, XtPointer client_data, XtPointer call_data) { if (numberofgroups > 0) { if (ADwin <= 0) { Change = TRUE; EditDemoFlag = 0; ADwin = initadwin(); popup_AddDemo(); InterfaceWinOpen++ ; } } else { sprintf(msgstring, "Because this is an early version of the\ndemobook, you must read in a demobook file\nbefore you can add more demos. Please\nchoose Open under the File Menu."); popup_Message(); } } void menuCB_Audio(Widget w, XtPointer client_data, XtPointer call_data) { if (!Audio) Audio = audio_lib_capable(); else Audio = !Audio; } void menuCB_DBHelp(Widget w, XtPointer client_data, XtPointer call_data) { system("showcase -v $DEMOS/src/demos/demobook/help.show"); } void menuCB_DHelp(Widget w, XtPointer client_data, XtPointer call_data) { if (seliconptr == NULL) { sprintf(msgstring, "Please select a demo before asking for help on a\nspecific demo. If you would like help on demobook,\nplease select Demobook from the help menu."); popup_Message(); } else { if (seliconptr->iconptr->helpfile == NULL) { sprintf(msgstring, "Sorry, the demo you have selected, %s, does not have help.",seliconptr->iconptr->nameptr->string); popup_Message(); } else { sprintf(msgstring, "showcase -v %s",seliconptr->iconptr->helpfile->name); system(msgstring); } } } void menuCB_BHelp(Widget w, XtPointer client_data, XtPointer call_data) { if (curgroup == NULL) { sprintf(msgstring, "Please open a book before asking for help on a\nspecific book. If you would like help on demobook,\nplease select Demobook from the help menu."); popup_Message(); } else { if (curgroup->helpfile == NULL) { sprintf(msgstring, "Sorry, the book you have selected, %s, does not have help.",curgroup->nameptr->string); popup_Message(); } else { printf(" helpfile is %s \n",curgroup->helpfile->name); sprintf(msgstring, "showcase -v %s",curgroup->helpfile->name); system(msgstring); } } } void menuCB_DelB(Widget w, XtPointer client_data, XtPointer call_data) { if (curgroup != NULL) { if ( deletegroup(curgroup) ) { Change = TRUE; drawscene(0); } DeleteGroupFlag = FALSE; } else { sprintf(msgstring, "To delete a book, open that book\nand then choose Delete Book from the\nBook Menu."); popup_Message(); } } void menuCB_DelD(Widget w, XtPointer client_data, XtPointer call_data) { if (selected >= 0) { Change = TRUE; deleteicon(curgroup, selected, gSide); drawscene(0); DeleteDemoFlag = FALSE; } else { sprintf(msgstring, "To delete a demo, select an icon on the\npage and then choose Delete Demo from\nthe Demos Menu."); popup_Message(); } } void menuCB_Location(Widget w, XtPointer client_data, XtPointer call_data) { char command_line[256]; if (selected >= 0) { /* Execute the find_location routine with the icon's "startstring". That routine strips out the demo's path from the startstring, and prints it out using xconfirm. */ sprintf( command_line, "./find_location '%s", seliconptr->iconptr->startstring ); strcat( command_line, "'" ); system(command_line); } else { sprintf(msgstring, "To find the location of a program, select\nan icon on the page and then choose\nFindLocation from the Options Menu."); popup_Message(); } } void menuCB_EditB(Widget w, XtPointer client_data, XtPointer call_data) { long rslt; #ifdef DEBUG printf(" waht happens when I want to edit a group when the group window is open?? \n"); #endif if (curgroup != NULL) { if ((rslt = editgroup()) > 0) { Change = TRUE; EditGroupFlag = 1; if (MotifGroupWin <= 0) { popup_CreateGroup(); MotifGroupWin = 99; InterfaceWinOpen++ ; } } else { sprintf(msgstring, "The Master Index is a special book and\ncannot be edited. It contains all of the\ndemos in the demobook in alphabetical order.\nIf you want to add a demo to the book,\nuse the add demo feature under\nthe Demos menu."); popup_Message(); } } else { sprintf(msgstring, "To edit a book, first make sure that no\nother books are open for editing (close\nthe book window). Then open that\nbook and select Edit Book from\nthe Book Menu."); popup_Message(); } } void menuCB_EditD(Widget w, XtPointer client_data, XtPointer call_data) { if (ADwin <= 0) { if (selected >= 0) { Change = TRUE; EditDemoFlag = 1; ADwin = initadwin(); create_AddDemo(); popup_AddDemo(); InterfaceWinOpen++ ; } else { sprintf(msgstring, "To edit demo information, please select\na demo by clicking on its icon before\nchoosing Edit Demo Info from the menu.\nTo add a new demo, choose Add Demo from\nthe Demos menu."); popup_Message(); } } } /* fix_file_buttons: this sets up whether you can select buttons under * the File menu, specifically the Open and Append buttons. You cannot * open another data file after the first file is read in; and you cannot * append to the file if you started demobook in View Only mode. */ void fix_file_buttons() { #ifdef DEBUG printf(" in fix file_buttons \n"); #endif if (firstgroup == NULL) /* if a file has NOT been read or specified */ { /* you can only open, but not append, a file */ XtVaSetValues(OpenButton, XmNsensitive, TRUE, NULL); XtVaSetValues(AppendButton, XmNsensitive, FALSE, NULL); } else /* if a file has been read */ { /* you can't open another file RATMAN */ XtVaSetValues(OpenButton, XmNsensitive, FALSE, NULL); if (ViewOnly) /* you cannot make changes in viewonly mode */ XtVaSetValues(AppendButton, XmNsensitive, FALSE, NULL); else XtVaSetValues(AppendButton, XmNsensitive, TRUE, NULL); } #ifdef DEBUG printf(" leaving fix file_buttons \n\n"); #endif } /* fix_zoom_buttons: this determines if you can choose on the zoom buttons. * if you've zoomed in a direction, you can't keep zooming that way more * than the first time. */ void fix_zoom_buttons() { if (closeup == -1) /* meaning we zoomed left */ { XtVaSetValues(ZLbutton, XmNsensitive, FALSE, NULL); XtVaSetValues(ZRbutton, XmNsensitive, TRUE, NULL); XtVaSetValues(ZObutton, XmNsensitive, TRUE, NULL); } else if (closeup == 0) /* meaning we zoomed out */ { XtVaSetValues(ZObutton, XmNsensitive, FALSE, NULL); XtVaSetValues(ZRbutton, XmNsensitive, TRUE, NULL); XtVaSetValues(ZLbutton, XmNsensitive, TRUE, NULL); } else if (closeup == 1) /* meaning we zoomed right */ { XtVaSetValues(ZRbutton, XmNsensitive, FALSE, NULL); XtVaSetValues(ZLbutton, XmNsensitive, TRUE, NULL); XtVaSetValues(ZObutton, XmNsensitive, TRUE, NULL); } } void menuCB_ZoomLeft(Widget w, XtPointer client_data, XtPointer call_data) { closeup = -1; fix_zoom_buttons(); dobookview(); drawscene(0); } void menuCB_ZoomRight(Widget w, XtPointer client_data, XtPointer call_data) { closeup = 1; fix_zoom_buttons(); dobookview(); drawscene(0); } void menuCB_ZoomOut(Widget w, XtPointer client_data, XtPointer call_data) { closeup = 0; fix_zoom_buttons(); dobookview(); drawscene(0); } void menuCB_CloseBook(Widget w, XtPointer client_data, XtPointer call_data) { XtVaSetValues(CBbutton, XmNsensitive, FALSE, NULL); selected = -1; prevselection = -1; seliconptr = NULL; close_book(); drawscene(0); fix_zoom_buttons(); } void menuCB_Hide(Widget w, XtPointer client_data, XtPointer call_data) { Hide = !Hide; setup_all_groups(); if (OPENBOOK) { if (leftpage != NULL) rightpage = leftpage->nextpage; } drawscene(0); } void menuCB_Index(Widget w, XtPointer client_data, XtPointer call_data) { popup_Index(); } void menuCB_Append(Widget w, XtPointer client_data, XtPointer call_data) { FileMode = 1; /* Read File */ if (RDwin <= 0) { UxPopupInterface(BookFile, no_grab); RDwin = 99; InterfaceWinOpen++ ; } } void menuCB_Open(Widget w, XtPointer client_data, XtPointer call_data) { FileMode = 1; /* Read File */ if (firstgroup == NULL) { if (RDwin <= 0) { UxPopupInterface(BookFile, no_grab); RDwin = 99; InterfaceWinOpen++ ; } } else { sprintf(msgstring, "Because this is an early version of the\ndemobook, you must restart the program\nto open a different demobook file."); popup_Message(); } } void menuCB_Save(Widget w, XtPointer client_data, XtPointer call_data) { Change = FALSE; if (numberofgroups > 0) { if (FileName == NULL) /* We should not get here. */ printf("Error: Book FileName is NULL. Nothing will be saved.\n"); else { DialogType = 7; popup_Question(); handleMessageEvents(); } } else { sprintf(msgstring, "\nThis demobook file is empty. Nothing will be saved.\n"); popup_Message(); } } void menuCB_SaveAs_binary(Widget w, XtPointer client_data, XtPointer call_data) { Change = FALSE; ASCII = FALSE; FileMode = 2; /* Write File */ if (numberofgroups > 0) { if (RDwin <= 0) { UxPopupInterface(BookFile, no_grab); RDwin = 99; InterfaceWinOpen++ ; } } else { sprintf(msgstring, "\nThis demobook file is empty. Nothing will be saved.\n"); popup_Message(); } } void menuCB_SaveAs_ascii(Widget w, XtPointer client_data, XtPointer call_data) { Change = FALSE; ASCII = TRUE; FileMode = 2; /* Write File */ if (numberofgroups > 0) { if (RDwin <= 0) { UxPopupInterface(BookFile, no_grab); RDwin = 99; InterfaceWinOpen++ ; } } else { sprintf(msgstring, "\nThis demobook file is empty. Nothing will be saved.\n"); popup_Message(); } } void menuCB_Tar(Widget w, XtPointer client_data, XtPointer call_data) { /* error checking that I will do again after I can use popup_Message() if (FileName == NULL) { sprintf(msgstring, "You must read in a demobook file before\nyou can create a tape. Please choose\nOpen under the File Menu."); popup_Message(); } else if (numberofgroups <= 0) { sprintf(msgstring, "\nThis demobook is empty. No tape will be created.\n"); popup_Message(); } else */ tar_files(); } void menuCB_Quit(Widget w, XtPointer client_data, XtPointer call_data) { if (Change) { popup_Quit(); } else { exit(1); } } /* create_menu_widget: creates menus for DemoBook. Parent is * topform. */ Widget create_menu_widget (Widget parent) { Widget menubar, menupane, submenupane, helpwidget; Widget button, cascade; Arg wargs[10]; int n; XmStringCharSet charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET; /* used to set up XmStrings */ /* create the entire top menu bar */ n = 0; XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++; menubar = XmCreateMenuBar (parent, "menubar", wargs, n); /* File placeholder for File menu */ n = 0; menupane = XmCreatePulldownMenu (menubar, "filepane", wargs, n); #ifdef HideMenu /* Open selection from File menu */ n = 0; OpenButton = XmCreatePushButton(menupane, "OpenButton", wargs, n); XtAddCallback(OpenButton, XmNactivateCallback, menuCB_Open, "Open"); XtManageChild(OpenButton); #endif #ifdef HideMenu /* Append selection from File menu */ n = 0; AppendButton = XmCreatePushButton(menupane, "AppendButton", wargs, n); XtAddCallback(AppendButton, XmNactivateCallback, menuCB_Append, "Append"); XtManageChild(AppendButton); fix_file_buttons(); /* determine sensitivity of Append and Open buttons */ #endif #ifdef HideSAVEMenu /* Save selection from File menu */ n = 0; button = XmCreatePushButton(menupane, "SaveButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_Save, "Save"); XtManageChild(button); /* Save As placeholder for Save As menu from File menu. This is a sub menu. */ n = 0; submenupane = XmCreatePulldownMenu (menupane, "saveaspane", wargs, n); /* Binary button from Save As selection */ n = 0; button = XmCreatePushButton(submenupane, "BinaryButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_SaveAs_binary, "Save As"); XtManageChild(button); /* Ascii button from Save As selection */ n = 0; button = XmCreatePushButton(submenupane, "AsciiButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_SaveAs_ascii, "Save As"); XtManageChild(button); /* Save As selection from File menu */ n = 0; XtSetArg (wargs[n], XmNsubMenuId, submenupane); n++; cascade = XmCreateCascadeButton (menupane, "SaveAsButton", wargs, n); XtManageChild (cascade); /* Michelle had this commented out. n = 0; button = XmCreatePushButton(menupane, "Save As", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_SaveAs, "Save As"); XtManageChild(button); */ #endif #ifdef BROKE /* Create Tape selection from File menu */ n = 0; button = XmCreatePushButton(menupane, "CreateTapeButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_Tar, "Create a Tape"); XtManageChild(button); #endif /* Seperator on File menu */ n = 0; button = XmCreateSeparator(menupane, "sep", wargs, n); XtManageChild(button); /* Quit selection on File menu */ n = 0; button = XmCreatePushButton(menupane, "QuitButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_Quit, "Quit"); XtManageChild(button); /* The File menu on the menu bar */ n = 0; XtSetArg (wargs[n], XmNsubMenuId, menupane); n++; cascade = XmCreateCascadeButton (menubar, "FilePane", wargs, n); XtManageChild (cascade); if (!ViewOnly) /* You don't get Demos or Books in viewonly mode */ { /* Demos placeholder for Demos menu */ n = 0; menupane = XmCreatePulldownMenu (menubar, "demospane", wargs, n); /* Add Demo selection on Demos menu */ n = 0; button = XmCreatePushButton(menupane, "AddDemoButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_AddD, "Add Demo"); XtManageChild(button); /* Delete Demo selection on Demos menu */ n = 0; button = XmCreatePushButton(menupane, "DeleteDemoButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_DelD, "Delete Demo"); XtManageChild(button); /* Edit Demo selection on Demos menu */ n = 0; button = XmCreatePushButton(menupane, "EditDemoButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_EditD, "Edit Demo Info"); XtManageChild(button); /* Demos menu */ #ifdef HideMenu n = 0; XtSetArg (wargs[n], XmNsubMenuId, menupane); n++; cascade = XmCreateCascadeButton (menubar, "DemosPane", wargs, n); XtManageChild (cascade); #endif /* Books placeholder for Books menu */ n = 0; menupane = XmCreatePulldownMenu (menubar, "bookspane", wargs, n); /* Add Book selection in Books menu */ n = 0; button = XmCreatePushButton(menupane, "AddButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_AddB, "Add Book"); XtManageChild(button); /* Delete Book selection in Books menu */ n = 0; button = XmCreatePushButton(menupane, "DeleteButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_DelB, "Delete Book"); XtManageChild(button); /* Edit Book selection in Books menu */ n = 0; button = XmCreatePushButton(menupane, "EditButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_EditB, "Edit Book Info"); XtManageChild(button); /* Book Menu */ #ifdef HideMenu n = 0; XtSetArg (wargs[n], XmNsubMenuId, menupane); n++; cascade = XmCreateCascadeButton (menubar, "BooksPane", wargs, n); XtManageChild (cascade); #endif } /* Options placeholder for Options menu. You always get this menu. */ n = 0; menupane = XmCreatePulldownMenu (menubar, "optionspane", wargs, n); /* Show All Demos selection in Options menu */ n = 0; if (Hide) /* want to hide demos that are not present, disable toggle */ XtSetArg (wargs[n], XmNset, FALSE); else XtSetArg (wargs[n], XmNset, TRUE); n++; button = XmCreateToggleButton(menupane, "Show All Demos", wargs, n); XtAddCallback(button, XmNvalueChangedCallback, menuCB_Hide, "Show All Demos"); XtManageChild(button); /* Close Book selection in Options menu */ n = 0; if (OPENBOOK) /* only available if book open */ XtSetArg (wargs[n], XmNsensitive, TRUE); else XtSetArg (wargs[n], XmNsensitive, FALSE); n++; CBbutton = XmCreatePushButton(menupane, "CloseButton", wargs, n); XtAddCallback(CBbutton, XmNactivateCallback, menuCB_CloseBook, "Close Book"); XtManageChild(CBbutton); /* Ratman added this */ n = 0; button = XmCreatePushButton(menupane, "FindLocation", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_Location, "FindLocation"); XtManageChild(button); /* Zoom Left selection */ n = 0; ZLbutton = XmCreatePushButton(menupane, "ZLeftButton", wargs, n); XtAddCallback(ZLbutton, XmNactivateCallback, menuCB_ZoomLeft, "Zoom Left"); XtManageChild(ZLbutton); /* Zoom Right Selection */ n = 0; ZRbutton = XmCreatePushButton(menupane, "ZRightButton", wargs, n); XtAddCallback(ZRbutton, XmNactivateCallback, menuCB_ZoomRight, "Zoom Right"); XtManageChild(ZRbutton); /* Zoom Out */ n = 0; ZObutton = XmCreatePushButton(menupane, "ZOutButton", wargs, n); XtAddCallback(ZObutton, XmNactivateCallback, menuCB_ZoomOut, "Zoom Out"); XtManageChild(ZObutton); fix_zoom_buttons(); /* Michelle left this commented out. if (audio_lib_capable()) { n = 0; if (Audio) XtSetArg (wargs[n], XmNset, TRUE); else XtSetArg (wargs[n], XmNset, FALSE); n++; button = XmCreateToggleButton(menupane, "Audio", wargs, n); XtAddCallback(button, XmNvalueChangedCallback, menuCB_Audio, "Audio"); XtManageChild(button); } */ /* Options placeholder for Options menu */ n = 0; XtSetArg (wargs[n], XmNsubMenuId, menupane); n++; cascade = XmCreateCascadeButton (menubar, "OptionsPane", wargs, n); XtManageChild (cascade); #ifdef DEBUG /* we only use this for debugging purposes */ n = 0; menupane = XmCreatePulldownMenu (menubar, "debugpane", wargs, n); n = 0; button = XmCreatePushButton(menupane, "print demos", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_debug_demos, NULL); XtManageChild(button); n = 0; button = XmCreatePushButton(menupane, "print books", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_debug_books, NULL); XtManageChild(button); n = 0; button = XmCreatePushButton(menupane, "print index", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_debug_index, NULL); XtManageChild(button); n = 0; XtSetArg (wargs[n], XmNsubMenuId, menupane); n++; cascade = XmCreateCascadeButton (menubar, "Debug", wargs, n); XtManageChild (cascade); #endif /* Help placeholder for Help menu */ n = 0; menupane = XmCreatePulldownMenu (menubar, "helppane", wargs, n); /* Demobook selection */ #ifdef HideMenu n = 0; button = XmCreatePushButton(menupane, "DemobookButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_DBHelp, "Demobook"); XtManageChild(button); #endif /* Demo selection */ n = 0; button = XmCreatePushButton(menupane, "DemoButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_DHelp, "Demobook"); XtManageChild(button); /* Book selection */ #ifdef HideMenu n = 0; button = XmCreatePushButton(menupane, "BookButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_BHelp, "Demobook"); XtManageChild(button); #endif /* Index selection */ #ifdef HideMenu n = 0; button = XmCreatePushButton(menupane, "IndexButton", wargs, n); XtAddCallback(button, XmNactivateCallback, menuCB_Index, "Index"); XtManageChild(button); #endif /* Help menu */ n = 0; XtSetArg (wargs[n], XmNsubMenuId, menupane); n++; cascade = XmCreateCascadeButton (menubar, "Help", wargs, n); XtManageChild (cascade); n = 0; XtSetArg (wargs[n], XmNmenuHelpWidget, cascade); n++; XtSetValues (menubar, wargs, n); XtManageChild (menubar); return(menubar); } /* create_widgets: create the menu widgets */ void create_widgets(Widget parent) /* parent is really DBtoplevel */ { Arg wargs[10]; int n; Widget topform, menu, GLframe; XtTranslations mytrans; n = 0; topform = XtCreateManagedWidget( "DemobookTopForm", /* arbitrary widget name */ xmFormWidgetClass, /* form widget class */ parent, /* parent widget */ wargs, /* argument list */ n); /* number of arguments */ menu = create_menu_widget(topform); /* menus are children of topform */ #ifdef DEBUG XSynchronize(XtDisplay(topform),TRUE); #endif n = 0; XtSetArg(wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(wargs[n],XmNtopWidget, menu); n++; XtSetArg(wargs[n], XmNbottomAttachment, XmATTACH_FORM); n++; XtSetArg(wargs[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(wargs[n], XmNrightAttachment, XmATTACH_FORM); n++; GLframe = XtCreateManagedWidget("GLframe", xmFrameWidgetClass, topform, wargs, n); mytrans = XtParseTranslationTable(defaultTranslations); n = 0; if (use_pups) glxconfig_Main[3].buffer = GLX_POPUP; XtSetArg(wargs[n], GlxNglxConfig, glxconfig_Main); n++; XtSetArg(wargs[n], use_pups?GlxNusePopup:GlxNuseOverlay, TRUE); n++; MainGL = GlxCreateMDraw(GLframe, "glwidget", wargs, n); XtAddCallback( MainGL, GlxNginitCallback, initCB_Main, NULL); XtAddCallback( MainGL, GlxNexposeCallback, exposeCB_Main, NULL); XtAddCallback( MainGL, GlxNresizeCallback, resizeCB_Main, NULL); XtAddCallback( MainGL, GlxNinputCallback, inputCB_Main, NULL); XtAddCallback( MainGL, use_pups?GlxNpopupExposeCallback:GlxNoverlayExposeCallback, overlayexposeCB_Main, NULL); XtManageChild(MainGL); XtAugmentTranslations(MainGL, mytrans); } main(argc,argv) int argc; char **argv; { int i; /* set everything to null at beginning */ Boolean BadCommand = FALSE; /* bad command line option flag */ Change = FALSE; FileName = NULL; /* this is the name of the data file */ leftpage = NULL; rightpage = NULL; HeadGrpChar = NULL; TailGrpChar = NULL; HeadChar = NULL; TailChar = NULL; headfile = NULL; numberoficons = 0; numberofgroups = 0; prevselection = -1; lastvertex = 0; selected = -1; currentbook = -1; numberofbooks = 0; color_mult = 1.0; Hide = FALSE; /* hide demos that aren't present */ Audio = FALSE; /* is audio flag set? */ msgstring = (char *)malloc( sizeof(char) * 500);/* immediately malloc space */ /* for the mesg string */ firsticon == NULL; lasticon == NULL; firstgroup = NULL; /* determines if file was read in ? */ lastgroup = NULL; demoenv = NULL; /* where do we look for demos? */ xenv = NULL; sbenv = NULL; ViewOnly = FALSE; /* won't let you change anything in viewonly mode */ #ifdef DEBUG printf(" about to do a getgdesc \n"); #endif if (getgdesc(GD_BITS_OVER_SNG_CMODE) < 2) /* first find out if we can use */ use_pups = TRUE; /* overlay or popup */ #ifdef DEBUG printf(" did a getgdesc and survived\n"); #endif demoenv = getenv("DEMOS"); /* is a demo env var set? */ if (demoenv != NULL) demoenvlen = strlen(demoenv); /* find the string length */ else { demoenv = (char *)malloc(5); /* otherwise, malloc space */ strcpy(demoenv, "/usr"); /* and set it to /usr */ demoenvlen = strlen(demoenv); /* and set its length */ } xenv = getenv("XDEMOS"); /* is xdemo env var set? */ if (xenv != NULL) xenvlen = strlen(xenv); /* find the length of it */ else { xenv = (char *)malloc(15); /* otherwise malloc space */ strcpy(xenv, "/usr/demos/bin"); /* and set it to /usr/demos/bin */ xenvlen = strlen(xenv); /* and set the length */ } sbenv = getenv("SBIN"); /* is sbin env. var set? */ if (sbenv != NULL) sbenvlen = strlen(sbenv); /* get its length */ else { sbenv = (char *)malloc(15); /* otherwise, malloc space */ strcpy(sbenv, "/usr/demos/bin"); /* and set to /usr/demos/bin */ sbenvlen = strlen(sbenv); /* and set its length */ } #ifdef DEBUG printf(" done with env variables \n"); #endif for (i = 1; i < argc; i++) /* lets look at args */ { char *arg = argv[i]; if (arg[0] == '-') { /* process command line switches */ int len = strlen (arg); switch (arg[1]) { case 'h': if (len >= 5 && strncmp(arg, "-hide", len) == 0) Hide = TRUE; /* hide demos that aren't present */ break; case 'v': ViewOnly = TRUE; /* kind of like 'demo' mode */ break; /* you can't change anything */ case 'a': if (len >= 6 && strncmp(arg, "-audio", len) == 0) Audio = TRUE; /* let's use sounds! */ break; default: BadCommand = TRUE; /* if nothing applies, it's bad */ break; } } /* if it doesn't have a - in front, it's a file name */ else { /* process command line parameters */ FileName = (char *)malloc( sizeof(char) * (strlen(argv[i]) +1) ); strcpy(FileName, argv[i]); } } DBtoplevel = XtAppInitialize( /* topmost widget */ &DBapp_context, "Demobook", NULL, 0, &argc, argv, NULL, NULL, 0); create_widgets(DBtoplevel); /* build the menus */ init_motif_interface(argc,argv); /* initialize motif interface */ XtRealizeWidget(DBtoplevel); setbusycursor(); /* draw init window */ Create_motif_widgets(); /* create remaining motif widgets */ installcmap(DBtoplevel, MainGL); /* install color map */ if (BadCommand) { sprintf(msgstring, "Could not interpret what you\ntyped on the command line:\nTry demobook [input filename] [-hide] [-audio] [-v]"); DialogType = 1; popup_Message(); } if (FileName != NULL) read_file(FileName); /* read the input file */ clearbusycursor(); /* clear init window */ exposeCB_Main(MainGL, 0, 0); /* draw complete window */ /* MB 5/4/93 temporarily taking the color picker out of demobook, it seems to cause lots of bugs. if (!ViewOnly) { setup_colors_widget(); } */ newgrpptr = NULL; curnewpage = NULL; curgroup = NULL; /* Play a musical intro */ if (Audio) { if ( audio_lib_capable() ) { if (access("/usr/sbin/playaiff", F_OK) == 0) { if (access("/usr/lib/sounds/prosonus/musictags/tag3.aiff", F_OK) == 0) system("playaiff /usr/lib/sounds/prosonus/musictags/tag3.aiff &"); else { sprintf(msgstring, "\nAudio file \n/usr/lib/sounds/prosonus/musictags/tag3.aiff\nnot found.\n"); popup_Message(); Audio = FALSE; } if (access("/usr/lib/sounds/prosonus/musictags/tag2.aiff", F_OK) != 0) Audio = FALSE; } else { sprintf(msgstring, "Audio program \n/usr/sbin/playaiff\nnot found."); popup_Message(); Audio = FALSE; } } else { sprintf(msgstring, "\nAudio capability is not \nsupported on this workstation.\n"); popup_Message(); Audio = FALSE; } } if (message_waiting) { popup_Message(); message_waiting = FALSE; } XtAppMainLoop(DBapp_context); }